package com.sanyou.controller;

import com.sanyou.pojo.OperLog;
import com.sanyou.pojo.vo.OperLogVo;
import com.sanyou.service.OperLogService;
import com.sanyou.utils.JSONResult;
import com.sanyou.utils.PagedResult;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(value = "时间线日志相关的接口",tags = {"时间线日志相关的Controller"})
@CrossOrigin
@RestController
@RequestMapping("/operlog")
public class OperLogController {

    @Autowired
    private OperLogService operLogService;

    @GetMapping("/query")
    public JSONResult queryByProductCode(String productCode, Integer page, Integer pageSize){
        if(page == null)
            page = 1;

        if(pageSize == null)
            pageSize = 20;

        if (StringUtils.isBlank(productCode))
            return JSONResult.errorMsg("阴极板编号不能为空!");

        PagedResult operLogVos = operLogService.queryByProductCode(productCode, page, pageSize);
        return JSONResult.ok(operLogVos);
    }
}
